package org.yinweichen.llm_dataset_backend.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.yinweichen.llm_dataset_backend.service.QuestionTagService;

import java.util.List;

@RestController
@RequestMapping("/api/question-tags")
@RequiredArgsConstructor
public class QuestionTagController {
    private final QuestionTagService questionTagService;

    @PostMapping("/{questionId}/{version}")
    public void addTag(@PathVariable Long questionId,
                      @PathVariable String version,
                      @RequestParam String tag) {
        questionTagService.addTag(questionId, version, tag);
    }

    @DeleteMapping("/{questionId}/{version}")
    public void removeTag(@PathVariable Long questionId,
                         @PathVariable String version,
                         @RequestParam String tag) {
        questionTagService.removeTag(questionId, version, tag);
    }



    @GetMapping("/all")
    public List<String> getAllTags() {
        return questionTagService.getAllTags();
    }

    @GetMapping("/{questionId}/{version}")
    public List<String> getTagsByQuestionIdAndVersion(@PathVariable Long questionId,
                                                    @PathVariable String version) {
        return questionTagService.getTagsByQuestionIdAndVersion(questionId, version);
    }
}